/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app;

import com.app.ThreadManager;

import app.gui.MainMenu;
import app.gui.scene.SceneObserver;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author sammael
 */
public class Ruletka extends Application implements SceneObserver {

    private Stage stage;
    public static void main(String[] args) {
        launch(args);
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
			
			@Override
			public void run() {
				ThreadManager.getInstance().stopAll();
				ThreadManager.getInstance().shoutdownNow();
				System.exit(0);
			}
		}));
    }
    
    @Override
    public void start(Stage primaryStage) {
        
        primaryStage.setTitle("Ruletka");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
        
        //StackPane root = new StackPane();
        //root.getChildren().add(btn);
        //primaryStage.setScene(new Scene(root, 300, 250));
        MainMenu main = new MainMenu();
        main.registerObserver(this);
        primaryStage.setScene(main.getScene());
        primaryStage.getIcons().setAll(new Image(Ruletka.class.getResourceAsStream("/tali.png")));
        primaryStage.show();
        
        stage = primaryStage;
    }

    @Override
    public void updateScene(Scene scene) {
        stage.setScene(scene);
        stage.show();
    }
}
